# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render

# 导入django rest framework 依赖
from rest_framework.views import APIView
from rest_framework.response import Response

from rest_framework import permissions
from rest_framework.response import Response
from rest_framework.decorators import api_view, permission_classes

# Create your views here.


class DemoView(APIView):
    def get(self, request, *args, **kwargs):
        return Response('测试 Demo.')


@api_view(http_method_names=['GET'])
@permission_classes((permissions.AllowAny,))
def getUserList(request):
    return Response([
        {"name": "admin", "password": "123"},
        {"name": "auditor", "password": "456"},
    ])


@api_view(http_method_names=['POST'])
@permission_classes((permissions.AllowAny,))
def setUser(request):
    return Response({
        "data": request.data,
        "test": "111"
    })